package edu.uwm.capstone.android.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import edu.uwm.capstone.util.DebugUtil;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.format.DateFormat;
import android.widget.TimePicker;

public class AndroidUtil {
	public static String getAndroidAsset(Activity paramActivity,
			String fileName) throws IOException {
		InputStream localInputStream = paramActivity.getAssets().open(
				fileName, 3);
		StringBuilder localStringBuilder = new StringBuilder();
		BufferedReader localBufferedReader = new BufferedReader(
				new InputStreamReader(localInputStream, "UTF8"));
		while (true) {
			String str = localBufferedReader.readLine();
			if (str == null)
				return localStringBuilder.toString();
			localStringBuilder.append(str);
			localStringBuilder.append('\n');
		}
	}

	public static String getApplicationVersion(Context paramContext) {
		try {
			String str = paramContext.getPackageManager().getPackageInfo(
					paramContext.getPackageName(), 0).versionName;
			return str;
		} catch (PackageManager.NameNotFoundException localNameNotFoundException) {
			DebugUtil.debug(paramContext, "Unexpected exception",
					localNameNotFoundException);
		}
		return null;
	}

	public static void setTimePicker24Hour(TimePicker paramTimePicker) {
		paramTimePicker.setIs24HourView(Boolean.valueOf(DateFormat
				.is24HourFormat(paramTimePicker.getContext())));
	}
}
